<include file="Public/header" /> 
<script src="__PUBLIC__/js/uploadify/jquery.uploadify.min.js"></script>

<!--主窗体-->
<div class="container app">
	<!--左侧菜单-->
	<include file="Public/sidebar" /> 
	<!--左侧菜单//-->
	
	<!-- mainCon -->
	<div id="mainCon" class="mainCon">
		<h4>站点设置</h4>
		<form class="form-horizontal" id="myform">
			<div class="form-group">
				<label for="site_name" class="col-sm-2 control-label">网站名称</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="site_name" id="site_name" value="<{$opt['site_name']}>" placeholder="站点名称">
				</div>
			</div>

			<div class="form-group">
				<label for="site_url" class="col-sm-2 control-label">网站地址</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="site_url" id="site_url" value="<{$opt['site_url']}>" placeholder="站点链接">
				</div>
			</div>

			<div class="form-group">
				<label for="email" class="col-sm-2 control-label">联系邮箱</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="email" id="email" value="<{$opt['email']}>" placeholder="联系邮箱">
				</div>
			</div>

			<div class="form-group">
				<label for="phone" class="col-sm-2 control-label">联系电话</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="phone" id="phone" value="<{$opt['phone']}>" placeholder="联系电话">
				</div>
			</div>

			<div class="form-group">
				<label for="weixin1" class="col-sm-2 control-label">微信公众号</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="weixin1" id="weixin1" value="<{$opt['weixin1']}>" placeholder="微信公众号">
				</div>
			</div>

			<div class="form-group">
				<label for="weixin2" class="col-sm-2 control-label">资金微信号</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="weixin2" id="weixin2" value="<{$opt['weixin2']}>" placeholder="资金微信号">
				</div>
			</div>

			<div class="form-group">
				<label for="weixin3" class="col-sm-2 control-label">技术微信号</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="weixin3" id="weixin3" value="<{$opt['weixin3']}>" placeholder="技术微信号">
				</div>
			</div>

			<div class="form-group">
				<label for="seo_key" class="col-sm-2 control-label">站点SEO关键字</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="seo_key" id="seo_key" value="<{$opt['seo_key']}>" placeholder="站点SEO关键字">
				</div>
			</div>

			<div class="form-group">
				<label for="seo_depict" class="col-sm-2 control-label">站点SEO描述</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="seo_depict" id="seo_depict" value="<{$opt['seo_depict']}>" placeholder="站点SEO描述">
				</div>
			</div>
			
			<div class="form-group">
				<label for="" class="col-sm-2 control-label">是否开放注册</label>
				<div class="col-sm-5">
				<div style="margin-top:6px;"></div>
				<label for="open_reg0">
					<input type="radio" name="open_reg" id="open_reg0" value="0" <if condition="$opt['open_reg'] == 0">checked</if>> 否
				</label>
				<label for="open_reg1">
					<input type="radio" name="open_reg" id="open_reg1" value="1" <if condition="$opt['open_reg'] == 1">checked</if>> 是
				</label>
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">会员文章审核</label>
				<div class="col-sm-5">
				<div style="margin-top:6px;"></div>
				<label for="article_review0">
					<input type="radio" name="article_review" id="article_review0" value="0" <if condition="$opt['article_review'] == 0">checked</if>> 否
				</label>
				<label for="article_review1">
					<input type="radio" name="article_review" id="article_review1" value="1" <if condition="$opt['article_review'] == 1">checked</if>> 是
				</label>
				</div>
			</div>
			
			<div class="form-group">
				<label for="" class="col-sm-2 control-label">开放自定义二维码</label>
				<div class="col-sm-5">
					<div style="margin-top:6px;"></div>
					<label for="open_custom_code0">
						<input type="radio" name="open_custom_code" id="open_custom_code0" value="0" <if condition="$opt['open_custom_code'] == 0">checked</if>> 否
					</label>
					<label for="open_custom_code1">
						<input type="radio" name="open_custom_code" id="open_custom_code1" value="1" <if condition="$opt['open_custom_code'] == 1">checked</if>> 是
					</label>
				</div>
			</div>

			
			
			<div class="form-group">
				<label for="" class="col-sm-2 control-label">非会员试用天数</label>
				<div class="col-sm-5">
				<div style="margin-top:6px;"></div>
					<span style="display:inline-block">
						<input type="text" class="form-control" name="probation" id="probation" value="<{$opt['probation']}>" placeholder="非会员试用期设置最大可设置14天" style="width:125px;display:inline-block">&nbsp;&nbsp;天
					</span>
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">用户注册协议内容</label>
				<div class="col-sm-5">
					<textarea name="article_prompt" id="article_prompt" cols="30" rows="10">
						<{$opt['article_prompt']}>
					</textarea>
					<{:A('Editor')->buildEditor('article_prompt');}>
				</div>
			</div>

			<div class="form-group">
				<label for="site_name" class="col-sm-2 control-label">自定义文章库名称</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="article_library_name" id="article_library_name" value="<{$opt['article_library_name']}>" placeholder="自定义文章库名称">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">全局分享图标</label>
				<div class="col-sm-5">
					<div class="upload-file-box" style="width:350px">
						<div class="radio col-sm-5">
							<a class="btn btn-default" id="uploadify">上传图片</a> <span style="margin-top:10px;float:left;color:#999">（仅允许上传1MB以内的图片）</span>
						</div>
						<div id="upload-file-view" class="OneImageBox upload-view">
							<div id="showimg">
						
								<if condition="!empty($opt['newspicture'])">
									<div style="width:100px;height:100px;border:1px solid #ccc;overflow:hidden;float:left;">
										<img src="<{$opt['newspicture']}>" style="width:100px;height:100px;float:left;margin:0 auto;padding:5px;">
										<div onclick="removeImg();" style="height:30px;width:100%;background:#000;opacity:.6;text-align:center;z-index:3;position:relative;bottom:30px;color:#fff;line-height:30px;float:left;cursor:pointer;">删除</div>
									</div>
									<input type="hidden" class="img_input" name="newspicture" value="<{$opt['newspicture']}>">
								</if>
							</div>
	
						</div>
					</div>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-default col-sm-2">保存</button>
				</div>
			</div>
		</form>
	</div>
	<!-- mainCon// -->
	
</div>
<!--主窗体//-->

<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/validate/messages_zh.js"></script>
<script>
$(function(){

	$("#myform").validate({
		rules : {

		},
		messages : {

		},
		submitHandler : function(form){
			var ajaxUrl = "<{:U('Admin/Option/setSiteOpt')}>";

			var index_num = $("#probation").val();

			if(index_num > 14){
				layer.open({
				    title: [
				        '非会员期限',
				    ],
				    content: '非会员试用期设置最大可设置14天'					    
				});

				return false;
			}				

			$.post(ajaxUrl,$(form).serialize(),function(r){
    			if(r.error == 1){
    				layer.alert(r.errmsg,{icon: 2});
    			}else{
    				layer.alert(r.errmsg,{icon: 1},function(){
    					window.location.href = "<{:U('Admin/Option/siteOpt',array('k'=>6,'sk'=>0))}>";
    				});
    			}
    			return false;
    		});
        	return false
		}
	});

	$('#seo_key').focus(function() {
		var index = layer.tips('用逗号[英文半角]分隔,字数推荐20字以内',"#seo_key",{time:0});
		$(this).blur(function() {
			layer.close(index);
		});
	});

	$('#seo_depict').focus(function() {
		var index = layer.tips('字数推荐150字以内',"#seo_depict",{time:0});
		$(this).blur(function() {
			layer.close(index);
		});
	});

	// 文件上传
	$("#uploadify").uploadify({
		'swf'           : '/Public/js/uploadify/uploadify.swf',
		'uploader'      : "<?php echo U('Admin/Gallery/uploadImg');?>",
		'fileTypeExts'	: '*.jpg;*.png;*.gif',
		'width'			: 90,
		'buttonText' : '<a class="btn btn-default" id="uploadify">上传图片</a>',
		'hideButton' : true,
		'multi': false,
		'fileObjName' : 'imgFile',
		'fileSizeLimit' : '1MB',
		'multi'    : false, //开启,多选文件
		'uploadLimit' : 10, //允许上传文件个数
		'onUploadError' : function(back) {
			
		},
		'onUploadStart' : function(file) {

    	},
		'onUploadSuccess' : function(file,data,response) {
			var r = jQuery.parseJSON(data);
			if(r.error == 0){
				var htm = '<div style="width:100px;height:100px;border:1px solid #ccc;overflow:hidden;float:left;margin-bottom:10px;">';
				htm += '<img src="/'+r.imgUrl+'" style="width:100px;height:100px;float:left;margin:0 auto;padding:5px;">';
				htm += '<div onclick="removeImg(this);" style="height:30px;width:100%;background:#000;opacity:.6;text-align:center;z-index:3;position:relative;bottom:30px;color:#fff;line-height:30px;float:left;cursor:pointer;">删除</div>';
				htm += '<input type="hidden" class="img_input" name="newspicture" value="/'+r.imgUrl+'"/>';
				htm += '</div>';

				$("#showimg").empty();
				$("#showimg").append(htm);
			}
		},
	
	});	

});

//移除图片
function removeImg(obj){
	console.log('123');
	$("#showimg").html('');
	$("#banner_picture").val('');
}
</script>

<include file="Public/footer" /> 